﻿Imports System.Data.OleDb
Public Class Cars_Details
    Inherits System.Web.UI.Page

    Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim url As String = Request.QueryString("ID")

            'Panel1.Visible = True
            'lblTempest1.Visible = True

            If url = 1 Then
                pnlTempest.Visible = True
                lblTempest1.Visible = True
                lblGSXstage1.Visible = False
                pnlGSX.Visible = False
                lblBoss1.Visible = False
                pnlBoss.Visible = False
            ElseIf url = 2 Then
                lblGSXstage1.Visible = True
                pnlGSX.Visible = True
                pnlTempest.Visible = False
                lblTempest1.Visible = False
                lblBoss1.Visible = False
                pnlBoss.Visible = False
            ElseIf url = 3 Then
                lblBoss1.Visible = True
                pnlBoss.Visible = True
                lblGSXstage1.Visible = False
                pnlGSX.Visible = False
                pnlTempest.Visible = False
                lblTempest1.Visible = False
            End If
        End If
    End Sub

    Public counter As Integer = 0
    Public pixName As String


    Public Sub btnLeft_Click(ByVal sender As Object, ByVal e As EventArgs)
        'previous
        If Convert.ToInt16(PicNo1.Text) >= 2 Then
            counter = Convert.ToInt16(PicNo1.Text)
            counter = counter - 1
            PicNo1.Text = Convert.ToString(counter)
            pixName = "pic" + counter.ToString() + ".jpg"

            InitPic1.ImageUrl = "~/Images/XL/Tempest/" + pixName


        End If
    End Sub

    Public Sub btnRight_Click(ByVal sender As Object, ByVal e As EventArgs)
        'next
        If Convert.ToInt16(PicNo1.Text) <= 2 Then
            counter = Convert.ToInt16(PicNo1.Text)
            counter = counter + 1
            PicNo1.Text = Convert.ToString(counter)
            pixName = "pic" + counter.ToString() + ".jpg"
            InitPic1.ImageUrl = "~/Images/XL/Tempest/" + pixName

        End If
    End Sub

    Public Sub btnLeft1_Click(ByVal sender As Object, ByVal e As EventArgs)
        'previous
        If Convert.ToInt16(PicNo2.Text) >= 2 Then
            counter = Convert.ToInt16(PicNo2.Text)
            counter = counter - 1
            PicNo2.Text = Convert.ToString(counter)
            pixName = "pic" + counter.ToString() + ".jpg"
            InitPic2.ImageUrl = "~/Images/XL/GSX_Stage1/" + pixName
        End If
    End Sub

    Public Sub btnRight1_Click(ByVal sender As Object, ByVal e As EventArgs)
        'next
        If Convert.ToInt16(PicNo2.Text) <= 2 Then
            counter = Convert.ToInt16(PicNo2.Text)
            counter = counter + 1
            PicNo2.Text = Convert.ToString(counter)
            pixName = "pic" + counter.ToString() + ".jpg"
            InitPic2.ImageUrl = "~/Images/XL/GSX_Stage1/" + pixName
        End If
    End Sub
    Public Sub btnLeft2_Click(ByVal sender As Object, ByVal e As EventArgs)
        'previous
        If Convert.ToInt16(PicNo3.Text) >= 2 Then
            counter = Convert.ToInt16(PicNo3.Text)
            counter = counter - 1
            PicNo3.Text = Convert.ToString(counter)
            pixName = "pic" + counter.ToString() + ".jpg"
            InitPic3.ImageUrl = "~/Images/XL/Boss/" + pixName
        End If
    End Sub

    Public Sub btnRight2_Click(ByVal sender As Object, ByVal e As EventArgs)
        'next
        If Convert.ToInt16(PicNo3.Text) <= 2 Then
            counter = Convert.ToInt16(PicNo3.Text)
            counter = counter + 1
            PicNo3.Text = Convert.ToString(counter)
            pixName = "pic" + counter.ToString() + ".jpg"
            InitPic3.ImageUrl = "~/Images/XL/Boss/" + pixName
        End If
    End Sub

    Public Sub imgBtnDet1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgBtnDet1.Click
        pnlinfo1.Visible = True
    End Sub

    Public Sub imgBtnDet2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgBtnDet1.Click
        pnlinfo2.Visible = True
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("carsconn").ConnectionString)
        Dim sql = "Insert into Vehicle_Comments (VehCom_Author,VehCom_Title,VehCom_Mesg,FK_ID) values (@Author, @Title, @Message, @ID)"
        Dim cmd = New OleDbCommand(sql, conn)
        conn.Open()
        cmd.Parameters.AddWithValue("@Author", txtAuthor.Text)
        cmd.Parameters.AddWithValue("@Title", txtTitle.Text)
        cmd.Parameters.AddWithValue("@Message", txtMessage.Text)
        cmd.Parameters.AddWithValue("@ID", Request.Params("ID"))
        cmd.ExecuteNonQuery()
        conn.Close()
        Response.Redirect("Car_Details.aspx?ID=" & Request.Params("ID"))

    End Sub
End Class